package objects;

import globals.Vector2D;

import java.util.ArrayList;

import org.newdawn.slick.Color;
import org.newdawn.slick.Graphics;
import org.newdawn.slick.geom.Circle;
import org.newdawn.slick.geom.Line;

import states.SlickGame;

public class RandomCircleEffect{
	public int groupSize=0;
	private int curTime; // Wave Effect Data
	private ArrayList<Wave> waveList;
	// default 30
	public static int rateWaveSpawn=900;	// global effects
	public static float rateWaveSpread=(float)(1.009); // default 1.12
	public static int maxWaveRadius=60;
	
	public RandomCircleEffect(int gS){
		curTime=0;
		waveList=new ArrayList<Wave>();
		groupSize=gS;
	}
	
	public void update(int delta){
		curTime += delta;
		if(curTime>rateWaveSpawn){
			curTime=0;
			for(int i=0; i<this.groupSize; i++){
				Color randomColor=new Color((float) (Math.random()%0.7+0.3), (float) (Math.random()%0.7+0.3), (float) (Math.random()%0.7+0.3));
				waveList.add(new CircleWave((int)(SlickGame.width*Math.random()), (int)(SlickGame.height*Math.random()), rateWaveSpread, randomColor));
			}
		}
		
		for(int i=0; i<waveList.size();i++){
			waveList.get(i).update();
			if(waveList.get(i).getRadius()>maxWaveRadius){
				waveList.remove(i);
				i--;
			}
		}
	}
	
	public void draw(Graphics g){
		if(!waveList.isEmpty()){
			for(int i=0; i<waveList.size();i++){
				waveList.get(i).draw(g);
			}
		}
				
	}

}
